package org.itstack.demo.design;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author: fanYuLe
 * @CreateTime: 2023-12-25  19:43
 * @Description:
 */
public class AuthController {

    private SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//时间格式化

    public AuthInfo doAuth(String uId, String orderId, Date authDate) throws ParseException {
        // 三级审批
        Date date = AuthService.queryAuthInfo("1000013", orderId);
        if(null==date){
            return new AuthInfo("0001","单号：",orderId," 状态：待三级负责人审批 ","王工");
        }

        //二级审批
        if(authDate.after(f.parse("2020-06-01 00:00:00"))&&authDate.before(f.parse("2020-06-25 23:59:59"))){
            date = AuthService.queryAuthInfo("1000012", orderId);
            if (null == date) {return new AuthInfo("0001", "单号：", orderId, " 状态：待二级负责人审批 ", "张经理");}
        }
        // 一级审批
        if (authDate.after(f.parse("2020-06-11 00:00:00")) && authDate.before(f.parse("2020-06-20 23:59:59"))) {
            date = AuthService.queryAuthInfo("1000011", orderId);
            if (null == date) {return new AuthInfo("0001", "单号：", orderId, " 状态：待一级负责人审批 ", "段总");}
        }

        return new AuthInfo("0001", "单号：", orderId, " 状态：审批完成");
    }

}
